/* GUI CONVERTED from adcsmtp.p (converter v1.76) Mon Jan 27 21:56:14 2003 */
/* adcsmtp.p  -  CUSTOMER  MAINTENANCE update frame b and frame b2            */
/* Copyright 1986-2003 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.40 $                                                              */
/*V8:ConvertMode=Maintenance                                                  */
/* REVISION: 7.4      LAST MODIFIED:    10/12/93     BY:   cdt    *H086*      */
/* REVISION: 7.4      LAST MODIFIED:    05/23/94     BY:   bcm    *H373*      */
/* REVISION: 7.4      LAST MODIFIED:    07/29/94     BY:   bcm    *H465*      */
/* REVISION: 7.4      LAST MODIFIED:    09/29/94     BY:   bcm    *H541*      */
/* REVISION: 7.4      LAST MODIFIED:    11/07/94     BY:   str    *FT44*      */
/* REVISION: 7.2      LAST MODIFIED:    01/12/95     BY:   ais    *F0C7*      */
/* REVISION: 7.4      LAST MODIFIED:    04/10/95     BY:   jpm    *H0CH*      */
/* REVISION: 7.4      LAST MODIFIED:    08/09/95     BY:   dxb    *H0FG*      */
/* REVISION: 8.5      LAST MODIFIED:    12/17/96     BY: *J1B6* Markus Barone */
/* REVISION: 8.5      LAST MODIFIED:    12/26/97     BY: *J28R* Seema Varma   */
/* REVISION: 8.5      LAST MODIFIED:    01/06/98     BY: *J299* Surekha Joshi */
/* REVISION: 8.6E     LAST MODIFIED:    02/23/98     BY: *L007* A. Rahane     */
/* REVISION: 8.6E     LAST MODIFIED:    04/18/98     BY: *L00R* Adam Harris   */
/* REVISION: 8.6E     LAST MODIFIED:    05/20/98     BY: *K1Q4* Alfred Tan    */
/* REVISION: 8.6E     LAST MODIFIED:    06/19/98     BY: *L01N* Robin McCarthy*/
/* REVISION: 8.6E     LAST MODIFIED:    07/21/98     BY: *L04G* Robin McCarthy*/
/* REVISION: 8.6E     LAST MODIFIED:    08/05/98     BY: *K1QS* Dana Tunstall */
/* REVISION: 8.6E     LAST MODIFIED:    08/05/98     BY: *K1RJ* Dana Tunstall */
/* REVISION: 8.6E     LAST MODIFIED:    08/18/98     BY: *K1DQ* Suresh Nayak  */
/* REVISION: 9.0      LAST MODIFIED:    11/09/98     BY: *M00R* Markus Barone */
/* REVISION: 9.0      LAST MODIFIED:    02/11/99     BY: *M082* Steve Nugent  */
/* REVISION: 9.0      LAST MODIFIED:    03/10/99     BY: *M0B3* Michael Amaladhas */
/* REVISION: 9.0      LAST MODIFIED:    03/13/99     BY: *M0BD* Alfred Tan    */
/* REVISION: 9.1      LAST MODIFIED:    10/01/99     BY: *N014* Robin McCarthy*/
/* REVISION: 9.1      LAST MODIFIED:    01/18/00     BY: *N077* Vijaya Pakala */
/* REVISION: 9.1      LAST MODIFIED:    02/04/00     BY: *N03S* Hemanth Ebenezer*/
/* REVISION: 9.1      LAST MODIFIED:    04/18/00     BY: *N03T* Jack Rief     */
/* REVISION: 9.1      LAST MODIFIED:    05/08/00     BY: *N0B0* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED:    08/17/00     BY: *N0LJ* Mark Brown    */
/* REVISION: 9.1      LAST MODIFIED:    10/17/00     BY: *M0V4* Kirti Desai   */
/* REVISION: 9.1      LAST MODIFIED:    09/20/00     BY: *N0W2* Mudit Mehta   */
/* Revision: 1.37     BY: Katie Hilbert DATE: 04/01/01   ECO: *P002*          */
/* Revision: 1.38     BY: Rajesh Kini   DATE: 09/26/01   ECO: *N136*          */
/* Revision: 1.39     BY: Hualin Zhong  DATE: 10/25/01   ECO: *P010*          */
/* $Revision: 1.40 $   BY: Amit Chaturvedi   DATE: 01/20/03   ECO: *N20Y*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

{mfdeclre.i}
{cxcustom.i "RMPMMTP.P"}
{gplabel.i} /* EXTERNAL LABEL INCLUDE */
{pxmaint.i}

/* THE CHANGES INTRODUCED BY ECO K1QS IN ADDSCLST.I AND ADPRCLST.I   */
/* AFFECT BOTH GRS AND NON GRS PROGRAMS. SINCE THE SCHEMA FOR  GRS   */
/* WAS INTRODUCED IN 8.6 AS OF 8.6C, THE ECO K1QS WAS CREATED FOR    */
/* ALL PROGRAMS INCLUDING GRS PROGRAMS. THE CORRESPONDING PATCH      */
/* FOR NON GRS PROGRAMS IS K1RJ. NO PROGRAM CHANGES HAVE BEEN        */
/* INTRODUCED BY ECO K1RJ.                                           */

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE adcsmtp_p_2 "Capture Self-Billing Information"
/* MaxLen: Comment:                                            */

/* ********** End Translatable Strings Definitions ********* */

/*fdn*/ define shared variable strSite like si_site .

define shared  variable mult_slspsn like mfc_logical no-undo.

define         variable is-union    like mfc_logical no-undo.
define         variable is-member   like mfc_logical no-undo.
define         variable old_curr    like pm_curr     no-undo.
define         variable new_curr    like pm_curr. /* CANNOT BE no-undo */

define shared frame a.
define shared frame b.
define shared frame b2.
define shared variable tax_recno    as   recid.
define shared variable pm_recno     as   recid.
define shared variable ad_recno     as   recid.
define shared variable undo_adcsmtc like mfc_logical.
define shared variable errfree      like mfc_logical.
define shared variable new_cmmstr   as   logical no-undo.

{&ADCSMTP-P-TAG1}
{etvar.i &new="new"}

/* DISPLAY SELECTION FORM */
{rmpmmt02.i}

/* FRAME TO UPDATE CUSTOMER TIME ZONE */
FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
space(1)
   ad_timezone
   space(2)
 SKIP(.4)  /*GUI*/
with frame tz-popup overlay row (frame-row(b2) - 1)
   centered side-labels attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-tz-popup-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame tz-popup = F-tz-popup-title.
 RECT-FRAME-LABEL:HIDDEN in frame tz-popup = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame tz-popup =
  FRAME tz-popup:HEIGHT-PIXELS - RECT-FRAME:Y in frame tz-popup - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME tz-popup = FRAME tz-popup:WIDTH-CHARS - .5.  /*GUI*/


/* SET EXTERNAL LABELS */
setFrameLabels(frame tz-popup:handle).

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
space(1)
   pm__qad06 label {&adcsmtp_p_2}
   space(1)
 SKIP(.4)  /*GUI*/
with frame selfbill overlay row (frame-row(b2) - 1)
   centered side-labels attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-selfbill-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame selfbill = F-selfbill-title.
 RECT-FRAME-LABEL:HIDDEN in frame selfbill = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame selfbill =
  FRAME selfbill:HEIGHT-PIXELS - RECT-FRAME:Y in frame selfbill - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME selfbill = FRAME selfbill:WIDTH-CHARS - .5.  /*GUI*/


/* SET EXTERNAL LABELS */
setFrameLabels(frame selfbill:handle).

find first gl_ctrl  no-lock no-error.

find first svc_ctrl no-lock no-error.

find pm_mstr where recid(pm_mstr) = pm_recno exclusive-lock no-error.
find ad_mstr where recid(ad_mstr) = ad_recno exclusive-lock no-error.

errfree = false.

loopb:
{&ADCSMTP-P-TAG2}
do on endkey undo, leave:
{&ADCSMTP-P-TAG3}

   {pxrun.i &PROC = 'setSortName' &PROGRAM = 'rmpuxr.p'
      &PARAM = "(buffer pm_mstr,
                 input ad_name)"
      &NOAPPERROR=true
      &CATCHERROR=true
      }

   ststatus = stline[3].
   status input ststatus.

   display
      pm_sort
      pm_type
      pm_region
      pm_slspsn[1]
      mult_slspsn
      pm_shipvia
      pm_resale
      pm_rmks
      pm_ar_acct
      pm_ar_sub
      pm_ar_cc
      pm_curr
      pm_lang
      pm_site
      /*fdn*/ strSite @ pm_site
      pm_scurr when (et_print_dc)
   with frame b.

   old_curr = pm_curr.

   if pm_curr <> ""
      and et_print_dc
   then do:

      /* CHECK IF CUSTOMER CURRENCY IS UNION CURRENCY */

      {pxrun.i &PROC = 'validateCurrencyInUnion' &PROGRAM = 'mcexxr.p'
         &PARAM = "(input pm_curr,
                    output union-curr,
                    output is-union,
                    output is-member)"
         &NOAPPERROR=true
         &CATCHERROR=true
         }

   end. /* IF pm_curr <> "" AND et_print_dc */

   setb:
   do on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.


      if old_curr <> pm_curr
         and pm_curr <> ""
         and et_print_dc
      then do:

         {pxrun.i &PROC = 'validateCurrency' &PROGRAM = 'rmpuxr.p'
            &PARAM = "(input pm_curr,
                       output is-union,
                       output is-member)"
            &NOAPPERROR=true
            &CATCHERROR=true
            }

      end.  /* IF pm_curr <> "" AND et_print_dc */

      hide frame tz-popup.

      set
         pm_sort
         pm_slspsn[1]
         mult_slspsn
         pm_shipvia
         pm_ar_acct
         pm_ar_sub
         pm_ar_cc
         pm_resale
         pm_rmks
         pm_type
         pm_region
         pm_curr
         pm_scurr when (et_print_dc
                   and (new_cmmstr
                    or is-union
                    or is-member
                    or new_curr <> old_curr))
        /*fdn* pm_site */
         pm_lang
      with frame b.

      /*fdn*/ assign pm_site.

      new_curr = input pm_curr.

      if pm_slspsn[1] <> ""
      then do:

         /* FIND THE sp_mstr RECORD. */

         {pxrun.i &PROC = 'processRead' &PROGRAM = 'adspxr.p'
            &PARAM = "(input pm_slspsn[1],
                       input false,
                       input false,
                       buffer sp_mstr)"
            &NOAPPERROR=true
            &CATCHERROR=true
            }
         if return-value <> {&SUCCESS-RESULT}
         then do:

            /* SALES PERSON DOES NOT EXIST */
            {pxmsg.i &MSGNUM=612 &ERRORLEVEL={&APP-ERROR-RESULT}}
            next-prompt pm_slspsn[1] with frame b.
            undo setb, retry.
         end. /* IF NOT AVAILABLE sp_mstr THEN DO: */

      end. /* IF pm_slspsn[1] <> "" THEN DO: */

      {pxrun.i &PROC = 'validateAccount' &PROGRAM = 'glacxr.p'
         &PARAM = "(input pm_ar_acct,
                    input pm_ar_sub,
                    input pm_ar_cc)"
         &NOAPPERROR=true
         &CATCHERROR=true
         }
      if return-value <> {&SUCCESS-RESULT}
      then do:

         next-prompt pm_ar_acct with frame b.
         undo, retry.
      end. /* IF return-value <> {&SUCCESS-RESULT} THEN DO: */

      {pxrun.i &PROC = 'validateCurrencyCode' &PROGRAM = 'rmpuxr.p'
         &PARAM = "(input old_curr,
                    input new_curr)"
         &NOAPPERROR=true
         &CATCHERROR=true
         }
      if return-value <> {&SUCCESS-RESULT}
      then do:

         next-prompt pm_curr with frame b.
         undo setb, retry.
      end. /* IF return-value <> {&SUCCESS-RESULT} THEN DO: */

      {pxrun.i &PROC = 'validateAccountCurrency' &PROGRAM = 'rmpuxr.p'
              &PARAM = "(input pm_ar_acct,
                         input pm_curr,
                         input base_curr)"
              &NOAPPERROR=true
              &CATCHERROR=true
      }
      if return-value <> {&SUCCESS-RESULT}
      then do:

         next-prompt pm_ar_acct with frame b.
         undo setb, retry.
      end. /* IF return-value <> {&SUCCESS-RESULT} */

      if pm_scurr <> ""
         and et_print_dc
      then do:

         /* VALIDATE RELATIONSHIP OF DUAL PRICING CURRENCY TO CUSTOMER
         CURRENCY.  THE CUSTOMER CURRENCY MUST BE AN EMU CURRENCY TO
         USE DUAL PRICING CURRENCY.  BOTH CURRENCIES CANNOT BE
         MEMBER CURRENCIES OR THE SAME CURRENCY. */

         if old_curr <> new_curr
         then do:

            {pxrun.i &PROC = 'validateCurrencyInUnion' &PROGRAM = 'mcexxr.p'
               &PARAM = "(input pm_curr,
                          output union-curr,
                          output is-union,
                          output is-member)"
               &NOAPPERROR=true
               &CATCHERROR=true
               }

         end.  /* IF old_curr <> pm_curr */

         {pxrun.i &PROC = 'validateUnionCurrency' &PROGRAM = 'mcexxr.p'
            &PARAM = "(input is-union,
                       input is-member)"
            &NOAPPERROR=true
            &CATCHERROR=true
            }

         if return-value <> {&SUCCESS-RESULT}
         then do:

            next-prompt pm_curr with frame b.
            undo setb, retry.
         end. /* IF return-value <> {&SUCCESS-RESULT} THEN DO: */

         /* VALIDATE DUAL PRICING CURRENCY CODE */

         {pxrun.i &PROC = 'validateCurrency' &PROGRAM = 'mcexxr.p'
            &PARAM = "(input pm_scurr)"
            &NOAPPERROR=true
            &CATCHERROR=true
            }

         if return-value <> {&SUCCESS-RESULT}
         then do:

            next-prompt pm_scurr with frame b.
            undo setb, retry.
         end. /* IF return-value <> {&SUCCESS-RESULT} THEN DO: */

         {pxrun.i &PROC = 'validateDualCurrencies' &PROGRAM = 'rmpuxr.p'
            &PARAM = "(input pm_curr,
                       input pm_scurr)"
            &NOAPPERROR=true
            &CATCHERROR=true
            }
         if return-value <> {&SUCCESS-RESULT}
         then do:

            next-prompt pm_scurr with frame b.
            undo setb, retry.
         end. /* IF return-value <> {&SUCCESS-RESULT} THEN DO: */

         /* IF CUSTOMER CURRENCY IS UNION CURRENCY, THEN DUAL PRICING
         CURRENCY MUST BE MEMBER CURRENCY. */
         if is-union
         then do:

            {pxrun.i &PROC = 'validateCurrencyIsMember' &PROGRAM = 'mcexxr.p'
               &PARAM = "(input pm_scurr,
                          output union-curr,
                          output is-member)"
               &NOAPPERROR=true
               &CATCHERROR=true
               }
            if not is-member
            then do:

               /* SECOND CURRENCY MUST BE EMU CURRENCY */
               {pxmsg.i &MSGNUM=2561 &ERRORLEVEL={&APP-ERROR-RESULT}}
               next-prompt pm_scurr with frame b.
               undo setb, retry.
            end. /* IF NOT is-member THEN DO: */
         end. /* IF is-union */
         else do:

            /* CUSTOMER CURRENCY IS A MEMBER CURRENCY, THEREFORE
            DUAL PRICING CURRENCY MUST BE UNION CURRENCY. */

            {pxrun.i &PROC = 'validateCurrencyIsUnion' &PROGRAM = 'mcexxr.p'
               &PARAM = "(input pm_scurr,
                          output is-union)"
               &NOAPPERROR=true
               &CATCHERROR=true
               }
            if not is-union
            then do:

               /* ONE CURRENCY MUST BE A UNION CURRENCY */
               {pxmsg.i &MSGNUM=2753 &ERRORLEVEL={&APP-ERROR-RESULT}}
               if old_curr <> pm_curr
               then
                  next-prompt pm_curr with frame b.
               else
                  next-prompt pm_scurr with frame b.
               undo setb, retry.
            end. /* if not is-union then do: */
         end.  /* ELSE DO */
      end.  /* IF pm_scurr <> "" AND et_print_dc */

      {pxrun.i &PROC = 'setSortFields' &PROGRAM = 'adadxr.p'
         &PARAM = "(buffer ad_mstr,
                    input pm_lang,
                    input pm_sort)"
         &NOAPPERROR=true
         &CATCHERROR=true
         }

      /* UPDATE MULTIPLE SALESPERSONS IN SUBROUTINE */
      if mult_slspsn
      then do:

         pm_recno = recid(pm_mstr).
         {gprun.i ""rmpmmta.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

      end. /* IF mult_slspsn THEN DO: */

      /* NEW FIELD ADDED AS pm__qadl01 */
      display
         pm_pr_list2
         pm_pr_list
         pm_fix_pr
         ad_taxable @ pm_taxable
         pm_sic
         pm_partial
         pm_class
         pm__qadl01
      with frame b2.

      setb2:
      do on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.


         set
            pm_pr_list2
            pm_pr_list
            pm_fix_pr
            pm_class
            pm_sic
            pm_partial
            pm__qadl01
         with frame b2.

         /* PRICE TABLE VALIDATION */
         /* ADDED TWO ARGUMENTS &DISP-MSG AND &WARNING */

         {adprclst.i &price-list     = "pm_mstr.pm_pr_list2"
            &curr           = "pm_mstr.pm_curr"
            &price-list-req = "no"
            &undo-label     = "setb2"
            &with-frame     = "with frame b2"
            &disp-msg       = "yes"
            &warning        = "yes" }

         /* DISCOUNT TABLE VALIDATION */
         /* ADDED TWO ARGUMENTS &DISP-MSG AND &WARNING */

         {addsclst.i &disc-list      = "pm_mstr.pm_pr_list"
            &curr           = "pm_mstr.pm_curr"
            &disc-list-req  = "no"
            &undo-label     = "setb2"
            &with-frame     = "with frame b2"
            &disp-msg       = "yes"
            &warning        = "yes" }

         undo_adcsmtc = true.
         {&ADCSMTP-P-TAG4}
         {gprun.i ""adcsmtc.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

         if undo_adcsmtc
         then
            undo setb2, retry.

         /* ALLOW UPDATE OF CUSTOMER TIME ZONE IF MTZ ENABLED */

         if {pxfunct.i &FUNCTION = 'ifMultiTimeZone' &PROGRAM = 'adadxr.p' }
         then do:

            display
               ad_timezone
            with frame tz-popup.

            /* IF AN END USER SHARES THE SAME ADDRESS RECORD, THEN   */
            /* THE TZ IS DISPLAY ONLY HERE, AND MUST BE CHANGED THRU */
            /* THE END USER TIME ZONE CHANGE UTILITY.                */

            if {pxfunct.i &FUNCTION = 'isTimeZoneEnabled' &PROGRAM = 'adadxr.p'
               &PARAM = "input ad_addr"
               }
            then do:

               {pxrun.i &PROC = 'getDefaultTimeZone' &PROGRAM = 'adadxr.p'
                  &PARAM = "(input ad_addr,
                             output ad_timezone)"
                  &NOAPPERROR=true
                  &CATCHERROR=true
                  }

               settz:
               do on error  undo, retry
                  on endkey undo setb, retry setb:
/*GUI*/ if global-beam-me-up then undo, leave.

                  set
                     ad_timezone
                  with frame tz-popup.

                  /* VALIDATE TIME ZONE AGAINST TZO_MSTR */

                  {pxrun.i &PROC = 'validateTimeZone' &PROGRAM = 'adadxr.p'
                     &PARAM = "(input ad_addr,
                                input ad_timezone)"
                     &NOAPPERROR=true
                     &CATCHERROR=true
                     }
                  if return-value <> {&SUCCESS-RESULT}
                  then
                     undo settz, retry settz.
               end.
/*GUI*/ if global-beam-me-up then undo, leave.
  /* settz */
            end.  /* IF isTimeZoneEnabled */
            else
               if not batchrun
               then
                  pause.

            hide frame tz-popup no-pause.
         end.  /* IF svc_multi_time_zones */

         if {pxfunct.i &FUNCTION = 'isSelfBilling' &PROGRAM = 'rmpuxr.p' }
         then do:

            do on endkey undo , leave:
               update
                  pm__qad06
               with frame selfbill.
            end. /* do on endkey undo , leave: */
            hide frame selfbill.
         end. /* IF isSelfBilling() THEN DO: */

      end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* setb2 */
   end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* setb */

   errfree = true.
   {&ADCSMTP-P-TAG5}
end. /* END LOOP B */
